package direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;
import org.junit.Test;
import utils.ConnectionUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author xj
 * @create 2021/8/12 13:31
 */
public class Provider {

    @Test
    public void providerTest() throws IOException, TimeoutException {

        Connection connection = ConnectionUtils.getConnection("localhost", 5672, "/xj", "xj", "123");
        Channel channel = connection.createChannel();
        /*定义交换机*/
        channel.exchangeDeclare("directName", "direct");
        /*发送消息*/
        String routingKey = "info";
        channel.basicPublish("directName", routingKey, null, "direcit-info信息".getBytes());
        channel.basicPublish("directName", "error", null, "direcit-error信息".getBytes());

        channel.close();
        connection.close();
    }
}
